package com.beiding.workordersystem.common.config;

import net.sf.ehcache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.ehcache.EhCacheCacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;

import java.io.IOException;
import java.net.URL;

@Configuration
@EnableCaching
public class CacheConfig {


    @Bean    //EhCahce缓存
    public CacheManager ehCacheManager() {
        net.sf.ehcache.CacheManager manager = net.sf.ehcache.CacheManager.newInstance();
        //java方式创建缓存
        Cache cache=new Cache("region",1024*2,true,false,10,10);
        manager.addCache(cache);
        return new EhCacheCacheManager(manager);
    }

}
